#include<bits/stdc++.h>
#define N 100010
using namespace std;
int n,m,T,l,v,ans;
struct car
{
    int d,v,a;
}c[N];
int p[N];
inline void read(int &x)
{
    x = 0;
    int f = 1;
    char s= getchar();
    while(s < '0' || s > '9')
    {
        if(s == '-') f = -1;
        s = getchar();
    }
    while(s >= '0' && s <= '9')
    {
        x = x * 10 + s - 48;
        s = getchar();
    }
    x *= f;
    return;
}
inline void write(int x)
{
    if(x < 0)
    {
        putchar('-');
        x *= -1;
    }
    if(x > 9) write(x / 10);
    putchar(x % 10 + 48);
    return;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    read(T);
    while(T --)
    {
        read(n),read(m),read(l),read(v);
        for(int i = 1;i <= n;i ++) read(c[i].d),read(c[i].v),read(c[i].a);
        for(int i = 1;i <= m;i ++) read(p[i]);
        sort(p + 1,p + 1 + m);
        int m_s = l;
        ans = 0;
        // cout << n << endl;
        for(int i = 1;i <= n;i ++)
        {
            if(c[i].v <= v) continue;
            m_s = min(m_s,c[i].d);
            ans ++;
        }
        // cout << ans << endl;
        write(ans);
        putchar(' ');
        if(m_s == l)
        {
            write(m);
            putchar('\n');
            continue;
        }
        write(m - 1);
        putchar('\n');
    }
    return 0;
}